
package com.phm.phmneuron;

import java.util.List;

/**
 *
 * @author PARHAM
 */
public class EuclideanDistanceMethod implements DistanceMethod {

    @Override
    public float distance(float[] data1, float[] data2) {
        float res = 0;
        for (int index = 0; index < data1.length; index++) {
            res += ((data1[index] - data2[index]) * (data1[index] - data2[index]));
        }
        return (float) Math.sqrt(res);
    }

    @Override
    public float [] distance(List<float[]> arr, float[] signal) {
        float [] res = new float [arr.size()];
        for (int index = 0; index < res.length; index++) {
            res [index] = distance(arr.get(index), signal);
        }
        return res;
    }

    @Override
    public float[] distanceDimension(float[] data1, float[] data2) {
        float [] res = new float [data1.length];
        for (int index = 0; index < data1.length; index++) {
            res [index] = data2 [index] - data1[index];
        }
        return res;
    }
    
}
